import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { fileURLToPath, URL } from "url"
// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/assets/styles/element-plus.scss" as *;`,
        silenceDeprecations: ['legacy-js-api'],
      },
    },
  },
  plugins: [vue(),
  AutoImport({
    resolvers: [ElementPlusResolver()],
    //安装两行后你会发现在组件中不用再导入ref，reactive等
    imports: ['vue', 'vue-router'],
    dts: "src/auto-import.d.ts",
  }),
  Components({
    resolvers: [ElementPlusResolver({ importStyle: "sass" })],
  }),],

  resolve: {
    alias: [
      {
        find: "@",
        replacement: fileURLToPath(new URL("./src", import.meta.url)),
      },
      {
        find: "#",
        replacement: fileURLToPath(new URL("./typings", import.meta.url)),
      },
    ],
  },
  server: {
    // Listening on all local IPs
    host: true,
    port: 8000,
  },
})
